﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using AddTab;
using System.Data.Linq;
using DevExpress.XtraBars.Helpers;
using DevExpress.UserSkins;
using Giao_dien_2.UserControl;

namespace Giao_dien_2
{
    public partial class Giaodien : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public Giaodien()
        {
            InitializeComponent();
        }
        AddTab.TabAdd classtab = new TabAdd();
        public void calltab(string tabname, DevExpress.XtraEditors.XtraUserControl formname)
        {
            int t = 0;
            foreach (DevExpress.XtraTab.XtraTabPage tab in xtraTabControl1.TabPages)
            {
                if (tab.Text == tabname)
                    t = 1;
            }
            if (t == 1)
            {

            }
            else
            {
                classtab.AddTab(xtraTabControl1, "", tabname, formname);
            }
        }
        public void reloadTab(string tabname)
        {

            foreach (DevExpress.XtraTab.XtraTabPage tab in xtraTabControl1.TabPages)
            {
               
                    
               
            }
        }
        #region xu li voi form dang nhap
        public string Manguoidung = "";
        public void ShowFormDangNhap()
        {           
            FormCT.FormDangNhap formdangnhap = new FormCT.FormDangNhap();
            formdangnhap.ShowDialog();
        }
        public void ShowFormDoiMatKhau()
        {
            FormCT.FormDoiMatKhau formdoimk = new FormCT.FormDoiMatKhau();
            formdoimk.manguoidung = Manguoidung;
            formdoimk.ShowDialog();

        }
        public void ShowFormSerVer()
        {
            FormCT.FormSerVer formsv = new FormCT.FormSerVer();
            formsv.ShowDialog();
        }
        private void Giaodien_Load(object sender, EventArgs e)
        {
            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.UserSkins.OfficeSkins.Register();
            DevExpress.UserSkins.BonusSkins.Register();
            SkinHelper.InitSkinPopupMenu(barSubItem1);
            ShowFormDangNhap();
        }
        #endregion

        private void barbtn_Dangnhaplai_ItemClick(object sender, ItemClickEventArgs e)
        {
             Giaodien_Load(sender, e);
        }

        private void barbtn_KetThuc_ItemClick(object sender, ItemClickEventArgs e)
        {
            Application.Exit();
        }

        private void barbtn_doimatkhau_ItemClick(object sender, ItemClickEventArgs e)
        {
            ShowFormDoiMatKhau();
        }

        private void barbtn_NHANVIENHC_ItemClick(object sender, ItemClickEventArgs e)
        {
            calltab("Nhân Viên Hành Chính", new UserControl.NHANVIENHANHCHINH());
        }

        private void barbtnDiachiServer_ItemClick(object sender, ItemClickEventArgs e)
        {
            FormCT.FormSerVer formsever = new FormCT.FormSerVer();
            formsever.ShowDialog();
        }

        private void barbtn_ChucVu_ItemClick(object sender, ItemClickEventArgs e)
        {
            calltab("Chức Vụ", new  UserControl.UC_ChucVu());
        }
       

        private void xtraTabControl1_ControlAdded(object sender, ControlEventArgs e)
        {
            xtraTabControl1.SelectedTabPageIndex = xtraTabControl1.TabPages.Count - 1;
        }

        private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e)
        {
            xtraTabControl1.TabPages.RemoveAt(xtraTabControl1.SelectedTabPageIndex);


        }
    }
}